<?php

	require_once($_SERVER['DOCUMENT_ROOT'] . '/auth/auth.php');

header('Expires: Sat, 26 Jul 1997 05:00:00 GMT');
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: pre-check=0, post-check=0, max-age=0');
header ('Pragma: no-cache'); 


	header('HTTP/1.1 301 Moved Permanently');
	header('Location: launch-vm.php');
	die();
	
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">


<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<meta http-equiv="pragma" content="nocache">

<title>Welcome!</title>
<link href="css/public.css" rel="stylesheet" type="text/css" />
</head>


<body>
<?php 
		$header_title = 'Welcome ' . $_SESSION['SESS_USER_FNAME'] . ' ' . $_SESSION['SESS_USER_LNAME'] . '!';
		include('header.php'); 
	?>

	<form class="summary">
		<?php

			function launchError($info) {
				$errarr = array();
				$errarr[] = $info;
				$_SESSION['ERRMSG_ARR'] = $errarr;
				session_write_close();
				header("location: auth/login-form.php");
				exit();
			}

			//Include database connection details
			require_once('db/config.php');

			//Connect to mysql server
			$link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);
			if($link) {
			
				$db = mysql_select_db(DB_DATABASE);
			
				if($db) {

					$qry="SELECT vmid, vmm_host, vmm_port FROM vm WHERE uid=" . $_SESSION['SESS_USER_ID'] . ";";
					$result=mysql_query($qry);
	
				if($result) {		
					if(mysql_num_rows($result) == 1) {
						$result = mysql_fetch_assoc($result);
						$vmid 	= $result['vmid'];
						$vmmhost = $result['vmm_host'];
						$vmmport = $result['vmm_port'];
					} else {
						launchError("No tienes niguna VM ID asociada, habla con sales@pxcloud.info para contratar una.");
					}
				}
			}}
	
				echo "<label>User</label><input type=\"text\" class=\"textfield\" value='[" . $_SESSION['SESS_USER_ID'] . "] " . $_SESSION['SESS_USER_USERNAME'] . "' />";
#				echo "<label>User ID</label><input type=\"text\" class=\"textfield\" value='" . $_SESSION['SESS_USER_ID'] . "' />";
#		        echo "<label>Username</label><input type=\"text\" class=\"textfield\" value='" . $_SESSION['SESS_USER_USERNAME'] . "' />";
#		        echo "<label>First Name</label><input type=\"text\" class=\"textfield\" value='" . $_SESSION['SESS_USER_FNAME'] . "  " . $_SESSION['SESS_USER_LNAME'] . "' />";
		        echo "<label>IP</label><input type=\"text\" class=\"textfield\" value='" . $_SESSION['SESS_USER_IP'] . "' />";
				echo "<label>VM Id</label><input type=\"text\" class=\"textfield\" value='" . $vmid . "' />";	
				echo "<label>VMM Host</label><input type=\"text\" class=\"textfield\" value='" . $vmmhost . "' />";					echo "<label>VMM Port</label><input type=\"text\" class=\"textfield\" value='" . $vmmport . "' />";
?>

	</form>

</body>
</html>
